// Copyright (c) Microsoft Corporation.  All rights reserved.
// DPWSSideShowDeviceSimulatorDlg.h : header file
//

#pragma once

#include "AutoButton.h"

// CDPWSSideShowDeviceSimulatorDlg dialog
class CDPWSServiceWrapper;

class CSideShowDisplayFormat
{
public:
    ULONG m_width;
    ULONG m_height;
    ULONG m_depth;

    CSideShowDisplayFormat(ULONG width, ULONG height, ULONG depth) :
        m_width(width),
        m_height(height),
        m_depth(depth)
    {
    }
};

//------------------------------------------------------------------------------
// CDPWSSideShowDeviceSimulatorDlg
//      Main window of device simulator
//------------------------------------------------------------------------------
class CDPWSSideShowDeviceSimulatorDlg : public CDialog
{
// Construction
public:
    CDPWSSideShowDeviceSimulatorDlg(CWnd* pParent = NULL);  // standard constructor

// Dialog Data
    enum { IDD = IDD_DPWSSIDESHOWDEVICESIMULATOR_DIALOG };

    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

public:

// Implementation
protected:
    HICON m_hIcon;

    // Generated message map functions
    virtual BOOL OnInitDialog();
    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnSize(UINT nType, int cx, int cy);
public:
    LRESULT OnSideshowUpdate(WPARAM wParam,
        LPARAM lParam);
private:
    // Instance of DPWS device and service wrapper 
    CDPWSServiceWrapper* m_pDPWSService;
public:
    afx_msg void OnDestroy();
    afx_msg void OnBnClickedBack();
    afx_msg void OnBnClickedMenu();
    afx_msg void OnBnClickedEnter();
    afx_msg void OnBnClickedLeft();
    afx_msg void OnBnClickedUp();
    afx_msg void OnBnClickedDown();
    afx_msg void OnBnClickedRight();

private:
    // buttons
    CAutoButton m_buttonBack;
    CAutoButton m_buttonMenu;
    CAutoButton m_buttonEnter;
    CAutoButton m_buttonLeft;
    CAutoButton m_buttonUp;
    CAutoButton m_buttonDown;
    CAutoButton m_buttonRight;

     // Windows SideShow members
public:
    CString GetClientID();
    void GetFrameBuffer(BYTE** pBuf, ULONG* size);
    void SetClientID(CString id);
    void PaintBitmap(BYTE* pBuf);
    void SetSideShowDisplayFormat(const CSideShowDisplayFormat& format);
    void GetSideShowDisplayFormat(CSideShowDisplayFormat& format) const;
    HRESULT InitializeSideShow();

private:

    HRESULT StartDPWSService();
    void StopDPWSService();
    bool AllocSideShowFrameBuffer();
    void FreeSideShowFrameBuffer();

    CSideShowDisplayFormat m_SideShowDisplayFormat;
    CString m_ClientID;
    BYTE* m_pBuffer;
    ULONG m_BufferSize;
    ULONG m_TextHeight;
};
